package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.SystemNotification;
import cn.wolfcode.trip.base.mapper.SystemNotificationMapper;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.ISystemNotificationService;
import cn.wolfcode.trip.base.util.UserContext;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class SystemNotificationServiceImpl implements ISystemNotificationService {

    @Autowired
    private SystemNotificationMapper systemNotificationMapper;

    public PageInfo listAll(QueryObject qo) {
        qo.setUserId(UserContext.getCurrentUser().getId());
        List list = systemNotificationMapper.query(qo);
        return new PageInfo(list) ;
    }

    public void saveOrUpdate(SystemNotification systemNotification) {
        systemNotificationMapper.insert(systemNotification);
    }

    @Override
    public int getsystemNotificationNum(QueryObject qo) {
        qo.setUserId(UserContext.getCurrentUser().getId());
        return systemNotificationMapper.getsystemNotificationNum(qo);
    }

    @Override
    public void updateType(QueryObject qo,int type) {
        Long userId = UserContext.getCurrentUser().getId();
        systemNotificationMapper.updateType(userId,type);
    }
}
